//
//  LDArtifactItem.m
//  Gift
//
//  Created by 李迪 on 15/11/17.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "LDArtifactItem.h"
#import "LDArtifactModel.h"
#import "BaseHeader.h"

@interface LDArtifactItem ()

@property (nonatomic, retain)UIImageView *image;
@property (nonatomic, retain)UILabel *title;


@end

@implementation LDArtifactItem


-(void)dealloc{
    
    [self.image release];
    [self.title release];
    [super dealloc];
    
}


- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self craeteItem];
    }
    return self;
}



- (void)craeteItem{
    self.image = [[UIImageView alloc]init];
    [self addSubview:self.image];
    
    self.title = [[UILabel alloc]init];
    [self addSubview:self.title];
    self.title.textAlignment = NSTextAlignmentCenter;
    
    [self.image release];
    [self.title release];
}


- (void)layoutSubviews{
    
    [super layoutSubviews];
    self.image.frame = CGRectMake(10, 0, 60, 60);
    self.title.frame = CGRectMake(0, 60, 75, 20);
    
}

- (void)setModel:(LDArtifactModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.icon_url]];
    self.title.text = model.name;
    
}



@end
